package com.example.yuejian21.nongfusanquan.yuejian21.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.view.ViewDebug;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.yuejian21.nongfusanquan.yuejian21.R;
import com.example.yuejian21.nongfusanquan.yuejian21.fragment.ActivityFragment;
import com.squareup.picasso.Picasso;

/**
 * Created by Nongfusanquan on 2017-10-12.
 */

public class ActivitydetailActivity extends AppCompatActivity {
    private TextView activitydetail_name,activitydetail_tel,activitydetail_info,
    activitydetail_address;
    private Button activitydetail_return,activitydetail_order;
    private ImageView activitydetail_pic;



    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_actvitydetail);
        initViews();
        initEvent();
        getData();

    }
    private void initViews(){
        activitydetail_name=(TextView)findViewById(R.id.activitydetail_name);
        activitydetail_tel=(TextView)findViewById(R.id.activitydetail_tel);
        activitydetail_info=(TextView)findViewById(R.id.activitydetail_info);
        activitydetail_return=(Button)findViewById(R.id.return_activitydetail);
        activitydetail_pic=(ImageView)findViewById(R.id.activitydetail_pic);
        activitydetail_address=(TextView)findViewById(R.id.activitydetail_num);
        activitydetail_order=(Button)findViewById(R.id.activitydetail_order);
    }

    private void initEvent(){
        activitydetail_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        Bundle bundle = this.getIntent().getExtras();
        final int a_id=bundle.getInt("a_id");
        activitydetail_order.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(ActivitydetailActivity.this, OrderactivityActivity.class);
                Bundle bundle = new Bundle();
                bundle.putInt("a_id", a_id);
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });
    }
    private void getData() {
        Bundle bundle = this.getIntent().getExtras();
        String aname = bundle.getString("a_name");
        String phone = bundle.getString("a_phone");
        String aintro =bundle.getString("a_info");
        String aaddress =bundle.getString("a_address");
        String apicture = "http://10.0.2.2/yuejian14/Public/Admin/activitypicture/"+bundle.getString("a_pic");

        activitydetail_name.setText(aname);
        activitydetail_tel.setText(phone);
        activitydetail_info.setText(aintro);
        activitydetail_address.setText(aaddress);



        Picasso.with(this).load(apicture).into(activitydetail_pic);
    }

}
